$(document).ready(function () {
  $(window).on("resize",function () {
    var items = $('.carousel-inner .item');
    var nWidth = $(window).width()
    if(nWidth > 992) {
      // 获取轮播图在992px以上屏幕的背景
      $(items).each(function () {
        var imgSrc = $(this).data("largeImage");
        $(this).html($('<a href="javascript:;" class="pcImg"></a>').css("backgroundImage","url('"+imgSrc+"')"));
      })
    }else {
      // 获取轮播图在992px以下屏幕的图片
      $(items).each(function () {
        var imgSrc = $(this).data("smallImage");
        $(this).html('<a href="javascript:;" class="mobileImg"><img src="'+imgSrc+'" alt="..."></a>');
      })
    }
  }).trigger("resize");

  // option-third动画
  // option-fourth动画
  var thirdTop = $(".option-third").offset().top;
  var fourthTop = $(".option-fourth").offset().top;
  $(window).scroll(function () {
    var windowTop = $(window).scrollTop();
    if(windowTop >= (thirdTop - 200)) {
      $(".option-third-img > picture").animate({"left": "0%"},2000);
      $(".option-third h2,h3,p").animate({"right": "0%"},2000);
    }
    if(windowTop >= (fourthTop - 200)) {
      // $(".option-fourth-text-p").animate({"left": "0%"},2000);
      $(".option-fourth-img > picture").animate({"right": "0%"},2000);
    }
  });
});